package top.soulblack.purchasesale.service;

import org.springframework.stereotype.Service;
import top.soulblack.purchasesale.mapper.SupplierMapper;
import top.soulblack.purchasesale.model.Supplier;

import javax.annotation.Resource;
import java.util.List;

/**
 * create by 小川
 */
@Service
public class SupplierService {

    @Resource
    private SupplierMapper supplierMapper;

    public List<Supplier> selectAll(){
        return supplierMapper.selectAll();
    }

    public void addSupplier(Supplier supplier){
        supplierMapper.addSupplier(supplier);
        return;
    }

    public boolean existSupplier(String name) {
        int num  = supplierMapper.existSupplier(name);
        if (num == 1) {
            return true;
        }
        return false;

    }
    public List<Supplier> selectForName(String supplierName) {
        return supplierMapper.selectForName(supplierName);
    }

    public boolean deleteSupplier(int announceId) {
        int num = supplierMapper.deleteById(announceId);
        if (num == 1) {
            return true;
        }
        return false;
    }

    public boolean updateSupplier(Supplier supplier) {
        int num = supplierMapper.updateByPrimaryKey(supplier);
        if (num == 1) {
            return true;
        }
        return false;
    }

    public Supplier selectById(Integer id){
        return supplierMapper.selectByPrimaryKey(id);
    }
}
